package com.smrtcold.dev.dto.task.defrost;

import com.smrtcold.dev.dto.dev.base.Point;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class DefrostTask {
    public final Point fan;
    public  Integer startHour;
    public  Integer startMinute;
    public Integer endHour;
    public Integer endMinute;
    public final int durationMinutes;
    private final String groupName;

    public DefrostTask(String groupName,Point fan, int totalStartMinutes, int duration ) {
        this.fan = fan;
        this.durationMinutes = duration;
        this.groupName = groupName;

        // 计算开始时间（处理跨天）
        totalStartMinutes %= 1440;
        this.startHour = totalStartMinutes / 60;
        this.startMinute = totalStartMinutes % 60;

        // 计算结束时间（处理跨天）
        int endTotalMinutes = totalStartMinutes + duration;
        endTotalMinutes %= 1440;
        this.endHour = endTotalMinutes / 60;
        this.endMinute = endTotalMinutes % 60;
    }

    @Override
    public String toString() {
        return String.format("风机%s 化霜时间: %s - %s (时长:%d分钟)",  fan.getName(), startHour, startMinute, durationMinutes);
    }
}
